package com.youth.koodoReaderManager.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.youth.koodoReaderManager.entity.Bookmark;
import com.youth.koodoReaderManager.mapper.BookmarkMapper;
import com.youth.koodoReaderManager.service.BookmarkService;
import org.springframework.stereotype.Service;

@Service
public class BookmarkServiceImpl extends ServiceImpl<BookmarkMapper, Bookmark> implements BookmarkService {

    @Override
    public IPage<Bookmark> pageQuery(IPage<Bookmark> page, Bookmark bookmark) {
        // 创建查询条件
        QueryWrapper<Bookmark> queryWrapper = new QueryWrapper<>();
        if (bookmark != null) {
            if (bookmark.getBookKey() != null && !ObjectUtil.isEmpty(bookmark.getBookKey())) {
                queryWrapper.eq("book_key", bookmark.getBookKey());
            }
            if (bookmark.getCfi() != null && !bookmark.getCfi().isEmpty()) {
                queryWrapper.eq("cfi", bookmark.getCfi());
            }
            // 其他字段的查询条件...
        }
        // 执行分页查询
        return this.page(page, queryWrapper);
    }
}